package org.gruposp2p.dnie.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
 *
 * @author jj
 */
@XmlType
@XmlRootElement(name = "DocumentTag")
@XmlAccessorType(XmlAccessType.NONE)
@Entity
@Table(name = "DOCUMENT_TAG", catalog = "DNIE")
@NamedQueries({
    @NamedQuery(name = "DocumentTag.findAll", query = "SELECT d FROM DocumentTag d"),
    @NamedQuery(name = "DocumentTag.findById", query = "SELECT d FROM DocumentTag d WHERE d.id = :id")})
public class DocumentTag implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    @XmlElement
    private Integer id;
    @JoinColumn(name = "DNIEDOCUMENTTOSIGN_ID", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    private DNIeDocumentToSign dnieDocumentToSignId;
    @JoinColumn(name = "DNIETAG_ID", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    private DNIeTag dnieTagId;

    public DocumentTag() {
    }

    public DocumentTag(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public DNIeDocumentToSign getDnieDocumentToSignId() {
        return dnieDocumentToSignId;
    }

    public void setDnieDocumentToSignId(DNIeDocumentToSign dnieDocumentToSignId) {
        this.dnieDocumentToSignId = dnieDocumentToSignId;
    }

    public DNIeTag getDnieTagId() {
        return dnieTagId;
    }

    public void setDnieTagId(DNIeTag dnieTagId) {
        this.dnieTagId = dnieTagId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DocumentTag)) {
            return false;
        }
        DocumentTag other = (DocumentTag) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.gruposp2p.dnie.model.DocumentTag[id=" + id + "]";
    }

}
